name: Test

on:
  push:
    branches:
      - "dev"
      - "develop"
  pull_request:
    branches:
      - "main"
      - "master"

jobs:
  tests-backend:
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres:16.3
        env:
          POSTGRES_PASSWORD: password
          POSTGRES_USER: postgres
          POSTGRES_DB: tests
        ports:
          - "5432:5432"
    steps:
      - name: Check out the repo
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: 3.12

      - name: Install Dependencies
        run: |
          cd backend/
          pip install -e .[dev]

      - name: Run tests
        env:
          DB_URI_TEST: postgresql+asyncpg://postgres:password@localhost:5432/tests
        run: |
          cd backend/
          pytest
